package com.moli.iov.his.service.impl;

import com.moli.iov.his.mapper.ReportSelledOnlineMapper;
import com.moli.iov.his.mapper.ReportStoreSelledOnlineMapper;
import com.moli.iov.his.model.po.ReportSelledOnline;
import com.moli.iov.his.model.po.ReportStoreSelledOnline;
import com.moli.iov.his.service.IReportStoreSelledOnlineService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moli.iov.his.util.HisUtil;
import com.moli.iov.rest.RestResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 门店、中转库已售车辆上线统计 服务实现类
 * </p>
 *
 * @author lxy
 * @since 2019-06-17
 */
@Service("reportStoreSelledOnlineService")
public class ReportStoreSelledOnlineServiceImpl extends ServiceImpl<ReportStoreSelledOnlineMapper, ReportStoreSelledOnline> implements IReportStoreSelledOnlineService {
    @Resource
    private ReportStoreSelledOnlineMapper reportStoreSelledOnlineMapper;

    @Override
    public RestResponse saveReportSelledOnline(ReportStoreSelledOnline reportStoreSelledOnline) {
        boolean save = save(reportStoreSelledOnline);
        return save ? RestResponse.success() : RestResponse.failure("新增已售车辆统计失败！");
    }

    @Override
    public List<ReportStoreSelledOnline> querySelledOnlineReport(String storeCode) throws Exception {
        List<ReportStoreSelledOnline> reportSelledOnlines = reportStoreSelledOnlineMapper.querySelledOnlineReport(storeCode);
        List<ReportStoreSelledOnline> ret = HisUtil.getStoreSelledOnlineDateReport(reportSelledOnlines);
        return ret;
    }

    @Override
    public List<ReportStoreSelledOnline> querySelledOnlineReportByTime(Map map) throws Exception {
        return reportStoreSelledOnlineMapper.querySelledOnlineReportByTime(map);
    }
}
